import axios from "axios";
import http from "@/api/http.js";
const baseUrl = "http://localhost:8091";
const taskRequest= {
    // 分页查询
    loadSelectAllTask(task,page=1,limit=10,callBack){
        let url = baseUrl + "/task/selectAll?page=" + page + "&limit=" + limit;
        if (task){
            if (task.taskId){
                url += "&taskId=" + task.taskId;
            }
            if (task.taskMaterialType){
                url += "&taskMaterialType=" + task.taskMaterialType;
            }
            if (task.taskGoodsName){
                url += "&taskGoodsName=" + task.taskGoodsName;
            }
        }
        axios.get(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
//     根据id查询数据信息
    loadSelectByIdTask(taskId,callBack){
        let url = baseUrl + "/task/selectById?taskId=" + taskId;
        axios.get(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
//     根据id删除数据信息
    loadDeleteTaskById(taskId,callBack){
        let url = baseUrl + "/task/delete?taskId=" + taskId;
        axios.delete(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
}
export default taskRequest;